@Inject('meetingService', 'ngDialogService')
class safeMeetingRegisterController {
  constructor() {
    this.data = {
      isEdit: false,
      activity: {
        name: '',
        startTime: '',
        organizer: '',
        site: '',
        speaker: '',
        recorder: '',
        content: '',
        attachmentId: null,
        files: [],
      },
    };
    this.view = {
      files: [],
    };
  }

  submitActivityForm() {
    this.data.activity.attachmentIds = this.view.files.map(item => item.id);
    this.meetingService.save(this.data.activity)
      .then((res) => {
        if (res.success) {
          this.ngDialogService.alertSuccess(res.message);
          window.history.go(-1);
        } else {
          this.ngDialogService.alertError(res.message);
        }
      });
  }
}

export default safeMeetingRegisterController;
